<?php

// Copyright 2022 Hackware SpA <human@hackware.cl>
// This file is part of "Hackware Web Services Payment" and licensed under
// the terms of the GNU Affero General Public License version 3, or (at your
// option) a later version. You should have received a copy of this license
// along with the software. If not, see <https://www.gnu.org/licenses/>.

return [
    'class' => '\Hawese\Payment\Gateways\PayPalGateway',
    'countries' => ['*'],
    'test_mode' => env('PAYPAL_TEST_MODE', false),
    'credentials' => [
        'clientId' => env('PAYPAL_CLIENT_ID'),
        'secretKey' => env('PAYPAL_SECRET_KEY')
    ],
    'payment_methods' => [
        'purchase' => 'payment_method'
    ],
    'schemas' => [
        'purchase' => [
            'required' => [
                'currency_code',
                'amount'
            ],
            'standard_map' => [
                'subject' => 'description',
                'email' => 'email_address',
                'due_amount' => 'amount',
                'payment_method' => 'payment_method',
                'currency' => 'currency_code'
            ],
            'properties' => [
                'description' => [ // purchase_units[].description
                    'title' => 'Descripción',
                    'type' => 'string',
                ],
                'currency_code' => [ // purchase_units[].amount.current_code
                    'title' => 'Moneda',
                    'type' => 'string',
                    'enum' => ['USD'],
                    'default' => 'USD',
                    'readOnly' => true,
                ],
                'amount' => [ // purchase_units[].amount.value
                    'title' => 'Monto',
                    'type' => 'number',
                    'multipleOf' => 0.01,
                ],
                'email_address' => [ // payer.email_address
                    'title' => 'Email',
                    'type' => 'string',
                    'format' => 'idn-email',
                ],
                'payment_method' => [ // for internal use, not sent to PayPal
                    'title' => 'Medio de pago',
                    'type' => 'string',
                    'oneOf' => [
                        [
                            'const' => 'paypal',
                            'title' => 'PayPal',
                            'description' => 'Cuenta PayPal y tarjetas con ' .
                                'cupo en dólares',
                            'image' => env('APP_URL') .
                                '/img/payment_methods/paypal.svg',
                        ]
                    ]
                ]
            ]
        ]
    ]
];
